package com.tsll.controller;


import com.tsll.service.VerifyApplicationService;
import com.tsll.service.VerifyBookService;
import com.tsll.vo.Result;
import com.tsll.vo.VerifyBookVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @author: Tian
 * @version: 1.0
 * @since: 1.0
 * @date: 2024/3/27/19:59
 */
@RestController
@RequestMapping("/verifyBook")
public class VerifyBookController {

    @Autowired
    VerifyApplicationService verifyApplicationServiceImpl;

    @Autowired
    VerifyBookService verifyBookServiceImpl;


    //根据verifyApplicationId查询书籍信息
    @RequestMapping("/selectByVerifyApplicationId/{current}/{pageSize}/{verifyApplicationId}")
    public  Result selectByVerifyApplicationId(@PathVariable Integer current, @PathVariable Integer pageSize, @PathVariable Integer verifyApplicationId){
        return verifyBookServiceImpl.selectByVerifyApplicationId(current,pageSize,verifyApplicationId);
    }

    //添加书籍审核信息
    @RequestMapping("/addVerify")
    public Result addVerify(@RequestBody List<VerifyBookVo> verifyBookVos){
        Integer id = verifyApplicationServiceImpl.insert();
        return  verifyBookServiceImpl.batchAdd(verifyBookVos,id);
    }


    //查询所用损坏的图书信息
    @RequestMapping("/searchAll/{current}/{pageSize}")
    public  Result searchAll(@PathVariable Integer current, @PathVariable Integer pageSize){
        return verifyBookServiceImpl.searchAll(current,pageSize);
    }

    /**
     * 修复损坏图书
     * @param verifyBookVos
     * @return
     */
    @RequestMapping("/updateRepairCount")
    public Result updateRepairCount(@RequestBody List<VerifyBookVo> verifyBookVos){
      return verifyBookServiceImpl.updateRepairCount(verifyBookVos);
    }


    /***
     * 清除损坏的图书
     * @param verifyBookVos
     * @return
     */
    @RequestMapping("updateClearCount")
    public Result updateClearCount(@RequestBody List<VerifyBookVo> verifyBookVos){
        return verifyBookServiceImpl.updateClearCount(verifyBookVos);
    }



}
